package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.query.QuestionAdminPageQuery;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "互动问答相关接口")
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
public class AdminQuestionController {

    private final IInteractionQuestionService interactionQuestionService;

    @GetMapping("/page")
    @ApiOperation("后台问题分页查询")
    PageDTO<QuestionAdminVO> gitAdminQuestionPage(QuestionAdminPageQuery query) {
        return interactionQuestionService.gitAdminQuestionPage(query);
    }

    @PutMapping("/{id}/hidden/{hidden}")
    @ApiOperation("修改问题隐藏状态")
    void updateQuestionHidden(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden) {
        interactionQuestionService.updateQuestionHidden(id, hidden);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询问题详情")
    QuestionAdminVO getQuestionById(@PathVariable("id") Long id) {
        return interactionQuestionService.getAdminQuestionById(id);
    }
}
